package com.sc.web.base;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sc.dal.model.base.BaseSku;
import com.sc.service.base.BaseSkuService;
import com.sc.util.data.DataUtil;
import com.sc.util.exception.ExceptionEnum;
import com.sc.util.exception.ScBizException;

/**
 * 基本规格管理
 * @author maoyongbin
 * @日期 Mar 28, 2017 4:15:12 PM
 */
@Controller
@RequestMapping(value="baseSku")
public class BaseSkuController {
	private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	private BaseSkuService baseSkuService;
	
	/**
	 * 查找所有的基本规格数据
	 * @return List<BaseSku>
	 */
	@RequestMapping(value="selectList", method=RequestMethod.GET)
	@ResponseBody
	public Map<String,Object> selectList(){
		Map<String,Object> resultMap = new LinkedHashMap<String,Object>();
		
		try{
			List<BaseSku> baseSkuList = this.baseSkuService.selectList();
			
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
			logger.info("查询基本规格数据成功!");
			
			resultMap.put("data", baseSkuList);
		}catch(Exception e){
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SELECT);
			logger.error("查询基本规格异常:"+e);
			throw new ScBizException("查询基本规格异常！", e);
		}
		
		return resultMap;
	}
}
